﻿@model string
<div class="main no-padding no-border">
    <table border=0 cellpadding=0 cellspacing=0 class="table table-bordered form-inline form-group-sm" id="tb_list">
        <thead>
            <tr>
                <td style="width:45px">选择</td>
                <td align="center">栏目</td>
            </tr>
        </thead>
        <tr>
            <td align="center"><input type="radio" id="id" name="id" value="0" class="theid"></td>
            <td align="center" style="text-align:left">一级栏目</td>
        </tr>
        <tr class="item parent_{parentGuid}" id='item_{id}' data-parentId="{parentId}" data-isFinal="{isFinal}" data-level="{level}" data-id="{id}">
            <td align="center"><input type="radio" id="id" name="id" value="{id}" class="checked-item checked-item-{id} final_{isFinal}"></td>
            <td align="center" style="text-align:left">{space}<span class="node node_{isFinal}"></span><span>{name}</span></td>
        </tr>
    </table>

    <div class="footerarea">
        提示：请选择要转移的目标栏目！
    </div>
    <div class="submit-footerbar">
        <form class=" form-group-sm form ui-validForm" method="post">
            <input type="hidden" name="targetId" id="targetId" value="0" />
            <input type="hidden" name="ids" id="ids" value="" />
            <button type="button" class="btn btn-sm  btn-primary ui-pagePost" data-custom-params="url:'@Url.ActionUrl()',beforeExecute:'BeforeExecuting',callBack:'PostCloseRefreshBack'">转移</button>
            <button type="button" class="btn btn-sm btn-default ui-closeDialog">关闭</button>
        </form>
    </div>

</div>
<script type="text/javascript">

    var defaultParams = {url:"@Url.ActionUrl("ListData")",showFooter:false,callBack: "LoadedInit"};
    $("#tb_list").TreeBind(defaultParams);

    function SetIds() {
        var $ids = $("#ids");
        var $parentIds = parent.$(".checked-item");
        var ids = $parentIds.GetChecked();
        var arrIds = ids.split(",");
        for (var i = 0; i < arrIds.length; i++) {
            $(".checked-item-" + arrIds[i]).attr("disabled", "disabled");
        }
        $ids.val(ids)
    }

    function LoadedInit()
    {
        SetIds();
        $(".final_1").attr("disabled", "disabled");
    }

    function BeforeExecuting() {
        var ids = $("#ids").val();
        if (ids == "")
        {
            Alert("您还没有选择要转移的栏目，请在父页面先选择!")
            return false;
        }
        var $targetId = $("[name = 'id']")
        var id = $targetId.GetChecked();
        if (id == "") {
            Alert("请选择要转移的目标栏目!")
            return false;
        }
        $("#targetId").val(id);
        return true;
    }
</script>